<?php 
namespace app\common\model;
use think\Model;
use think\Db;

class Shop extends Model
{
	public function reader($size)
	{
	    $res = Db::name('goods')
	    ->order('goods_id asc')
	    ->paginate($size);
	    
	    // echo url('picture');
	    return $res;
	}
	public function category($size,$pid)
	{
		$pid=input('pid');
	   // $res = Db::name('category')
		//->where('parent_id', $pid)
	   // ->order('cate_id asc')
	   // ->paginate($size);	
	    // echo url('picture');
	   // return $res;
		$res = Db::name('category')->where('parent_id', $pid)->order('cate_id asc')->paginate($size);
        $data = $res->all() ;
				foreach($data as $k => $v){
				          $res2 = Db::name('category')->where("parent_id",$v['cate_id'])->select();
				          $data[$k]['children'] = $res2;
                  $res->offsetSet($k,$data[$k]); 
                     
				}
                // $res->offsetSet($k,$data);
				return $res;
		
	}
}